import  sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
global sec
sec=0

def setTime():
    global  sec
    sec+=1
    lcdNmber.display(sec)
def worK():
    timer.start(1000)
    for i in  range(300000000):
        pass
    timer.stop()
    #pyqt所有窗口都在主线程    执行耗时操作的话会让窗口停止

if __name__ == '__main__':
    app=QApplication(sys.argv)
    top=QWidget()
    top.resize(300,150)
    layout=QVBoxLayout(top)
    #显示面板
    lcdNmber=QLCDNumber()
    layout.addWidget(lcdNmber)
    btton=QPushButton("测试")
    layout.addWidget(btton)
    timer=QTimer()
    timer.timeout.connect(setTime)
    btton.clicked.connect(worK)
    top.show()
    sys.exit(app.exec_())
